﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx;
using System.Threading;
using System.Windows.Media;
using Styx.Common;
using Styx.Common.Helpers;
using Styx.CommonBot;
using Styx.CommonBot.POI;
using Styx.CommonBot.Routines;
using Styx.Helpers;
using Styx.Pathing;
using Styx.Plugins;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using System.Diagnostics;

namespace RaidHunter
{
    public partial class Main : CombatRoutine
    {
        private static Stopwatch petPresenceTimer = new Stopwatch();
        private static Stopwatch dismountTimer = new Stopwatch();


        public int Misdirection = 34477;
        public int SerpentSting = 1978;
        public int SerpentStingAura = 118253;
        public int ExplosiveShot = 53301;
        public int CobraShot = 77767;
        public int ArcaneShot = 3044;
        public int MultiShot = 2643;
        public int KillShot = 53351;
        public int BlackArrow = 3674;
        public int MurderOfCrows = 131894;
        public int SilencingShot = 34490;
        public int FeignDeath = 5384;
        public int RapidFire = 3045;
        public int Disengage = 781;
        public int Deterrence = 19263;
        public int ConcussiveShot = 5116;
        public int TrapLauncher = 77769;
        public int FreezingTrap = 60192;
        public int ExplosiveTrap = 82939;
        public int SnakeTrap = 82948;
        public int IceTrap = 82941;
        public int StoneForm = 20894;
        public int Camouflage = 51753;
        public int RevivePet = 982;
        public int MendPet = 136;
        public int MastersCall = 53271;
        public int HuntersMark = 1130;
        public int Flare = 1543;
        public int Readiness = 23989;
        public int Stampede = 121818;
        public int DireBeast = 120679;
        public int AspectIronHawk = 109260;
        public int GlaiveToss = 117050;
        public int ScatterShot = 19503;
        public int WidowVenom = 82654;
        public int TranquilizingShot = 19801;
        public int LockAndLoad = 56343;
        public int BloodFury = 20572;
        public int Berserking = 26297;
        public int Powershot = 109259;
        public int Barrage = 120360;
        public int LynxRush = 120697;
        public int BlinkStrike = 130392;
        public int Fervor = 82726;
        public int ThrillOfTheHunt = 109306;

        public string useSpell(int spell)
        {
            string mySpell = "";

            switch (spell)
            {
                case 56343: mySpell = "Lock and Load"; break;
                case 19801: mySpell = "Tranquilizing Shot"; break;
                case 82654: mySpell = "Widow Venom"; break;
                case 19503: mySpell = "Scatter Shot"; break;
                case 117050: mySpell = "Glaive Toss"; break;
                case 109260: mySpell = "Aspect of the Iron Hawk"; break;
                case 120679: mySpell = "Dire Beast"; break;
                case 121818: mySpell = "Stampede"; break;
                case 23989: mySpell = "Readiness"; break;
                case 34477: mySpell = "Misdirection"; break;
                case 1978: mySpell = "Serpent Sting"; break;
                case 53301: mySpell = "Explosive Shot"; break;
                case 77767: mySpell = "Cobra Shot"; break;
                case 3044: mySpell = "Arcane Shot"; break;
                case 2343: mySpell = "Multi-Shot"; break;
                case 53351: mySpell = "Kill Shot"; break;
                case 3674: mySpell = "Black Arrow"; break;
                case 131894: mySpell = "A Murder of Crows"; break;
                case 34490: mySpell = "Silencing Shot"; break;
                case 5384: mySpell = "Feign Death"; break;
                case 3045: mySpell = "Rapid Fire"; break;
                case 781: mySpell = "Disengage"; break;
                case 19263: mySpell = "Deterrence"; break;
                case 5116: mySpell = "Concussive Shot"; break;
                case 77769: mySpell = "Trap Launcher"; break;
                case 60192: mySpell = "Freezing Trap"; break;
                case 82939: mySpell = "Explosive Trap"; break;
                case 82948: mySpell = "Snake Trap"; break;
                case 82941: mySpell = "Ice Trap"; break;
                case 20894: mySpell = "Stone Form"; break;
                case 51753: mySpell = "Camouflage"; break;
                case 982: mySpell = "Revive Pet"; break;
                case 136: mySpell = "Mend Pet"; break;
                case 53271: mySpell = "Master's Call"; break;
                case 1130: mySpell = " Hunter's Mark"; break;
                case 1543: mySpell = "Flare"; break;
                case 20572: mySpell = "Blood Fury"; break;
                case 26297: mySpell = "Berserking"; break;
            }
            return mySpell;
        }

        public string HavePotionBuff = "";
        public string HaveFlaskBuff = "";
        public string HaveHealPotions = "";
        public string HaveLifeSpirit = "";
        public string HaveHealthStone = "";
        public string LastSpell = "";

        public void UseTrinket1()
        {
            if (Me.CurrentTarget != null
                && Me.CurrentTarget.IsAlive
                && Me.Combat)
            {

                var firstTrinket = StyxWoW.Me.Inventory.Equipped.Trinket1;
                if (RaidHunterSettings.myPrefs.trinket1 == 2
                    && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs)
                {

                    if (firstTrinket != null && CanUseEquippedItem(firstTrinket))
                    {
                        firstTrinket.Use();
                        LogMsg("Using 1st trinket", 2);
                    }
                }
                if (RaidHunterSettings.myPrefs.trinket1 == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs)
                {
                    if (firstTrinket != null && CanUseEquippedItem(firstTrinket))
                    {
                        firstTrinket.Use();
                        LogMsg("Using 1st trinket", 2);
                    }
                }
            }
        }
        public void UseTrinket2()
        {

            if (Me.CurrentTarget != null
                && Me.CurrentTarget.IsAlive
                && Me.Combat)
            {
                var secondTrinket = StyxWoW.Me.Inventory.Equipped.Trinket2;


                if (RaidHunterSettings.myPrefs.trinket2 == 2
                    && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs)
                {

                    if (secondTrinket != null && CanUseEquippedItem(secondTrinket))
                    {
                        secondTrinket.Use();
                        LogMsg("Using 2nd trinket", 2);
                    }
                }
                else if (RaidHunterSettings.myPrefs.trinket2 == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs)
                {
                    if (secondTrinket != null && CanUseEquippedItem(secondTrinket))
                    {
                        secondTrinket.Use();
                        LogMsg("Using 2nd trinket", 2);
                    }
                }
            }
        }
        public void UseEngiGloves()
        {

            if (Me.CurrentTarget != null
                && Me.CurrentTarget.IsAlive
                && Me.Combat)
            {
                var engiGloves = StyxWoW.Me.Inventory.Equipped.Hands;

                if (RaidHunterSettings.myPrefs.engigloves == 2
                    && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs)
                {
                    if (engiGloves != null && CanUseEquippedItem(engiGloves))
                    {
                        engiGloves.Use();
                        LogMsg("Using Engineer Gloves", 2);
                    }
                }
                else if (RaidHunterSettings.myPrefs.engigloves == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs)
                {
                    if (engiGloves != null && CanUseEquippedItem(engiGloves))
                    {
                        engiGloves.Use();
                        LogMsg("Using Engineer Gloves", 2);
                    }
                }
            }
        }


        public void NeedMisdirection()
        {
            if (Me.CurrentTarget != null
                    && Me.CurrentTarget.IsAlive
                    && RaidHunterSettings.myPrefs.misdirection == 1
                    && !buffExists(Misdirection, Me)
                    && Me.CurrentTarget.ThreatInfo.RawPercent > 75
                    && !spellOnCooldown(Misdirection))
            {
                Lua.DoString("RunMacroText('/cast [@focus,help][help][@pet,exists] Misdirection');");
                {
                    LogMsg(">> Misdirection <<", 0);
                }
            }
        }
        #region pause

        public bool Paused = false;
        public bool PauseAoe = false;
        public override void ShutDown()
        {
            Lua.Events.DetachEvent("MODIFIER_STATE_CHANGED", HandleModifierStateChanged);
        }

        private void HandleModifierStateChanged(object sender, LuaEventArgs args)
        {
            if (RaidHunterSettings.myPrefs.PauseKeys == RaidHunterSettings.Keypress.None
                && RaidHunterSettings.myPrefs.PauseCRKeys == RaidHunterSettings.Keypress.None)
            {
                return;
            }
            if (Convert.ToInt32(args.Args[1]) == 1)
            {
                if (args.Args[0].ToString() == RaidHunterSettings.myPrefs.PauseKeys.ToString())
                {
                    PauseAoe = !PauseAoe;
                    if (PauseAoe)
                    {
                        Logging.Write("Aoe turned off, press {0} in WOW again to turn back on",
                                     RaidHunterSettings.myPrefs.PauseKeys.ToString());
                        if (RaidHunterSettings.myPrefs.PrintMsg)
                            Lua.DoString(
                                "RaidNotice_AddMessage(RaidWarningFrame, \"Aoe Turned off\", ChatTypeInfo[\"RAID_WARNING\"]);");
                    }
                    else
                    {
                        Logging.Write("Turning Aoe back on");
                        if (RaidHunterSettings.myPrefs.PrintMsg)
                            Lua.DoString(
                                "RaidNotice_AddMessage(RaidWarningFrame, \"Aoe turned on\", ChatTypeInfo[\"RAID_WARNING\"]);");
                    }
                }
            }
            if (Convert.ToInt32(args.Args[1]) == 1)
            {
                if (args.Args[0].ToString() == RaidHunterSettings.myPrefs.PauseCRKeys.ToString())
                {
                    Paused = !Paused;
                    if (Paused)
                    {
                        Logging.Write("Raidhunter Paused, press {0} in WOW again to turn back on",
                                     RaidHunterSettings.myPrefs.PauseCRKeys.ToString());
                        if (RaidHunterSettings.myPrefs.PrintMsg)
                            Lua.DoString(
                                "RaidNotice_AddMessage(RaidWarningFrame, \"Raidhunter paused\", ChatTypeInfo[\"RAID_WARNING\"]);");
                    }
                    else
                    {
                        Logging.Write("Raidhunter running again ....");
                        if (RaidHunterSettings.myPrefs.PrintMsg)
                            Lua.DoString(
                                "RaidNotice_AddMessage(RaidWarningFrame, \"Raidhunter running again ....\", ChatTypeInfo[\"RAID_WARNING\"]);");
                    }
                }
            }
        }
        #endregion pause

        private static bool CanUseEquippedItem(WoWItem item)
        {
            // Check for engineering tinkers!
            string itemSpell = Lua.GetReturnVal<string>("return GetItemSpell(" + item.Entry + ")", 0);
            if (string.IsNullOrEmpty(itemSpell))
                return false;


            return item.Usable && item.Cooldown <= 0;
        }


        #region spellcooldown
        public static TimeSpan GetSpellCooldown(string spell)
        {
            SpellFindResults results;
            if (SpellManager.FindSpell(spell, out results))
            {
                if (results.Override != null)
                    return results.Override.CooldownTimeLeft;
                return results.Original.CooldownTimeLeft;
            }


            return TimeSpan.MaxValue;
        }
        #endregion spellcooldown

        #region logs
        public void LogMsg(string msg, int kleurtje)
        {
            Color kleur = Colors.Yellow;
            switch (kleurtje)
            {
                case 0:
                    kleur = Colors.Orange;
                    break;
                case 1:
                    kleur = Colors.PaleGreen;
                    break;
                case 2:
                    kleur = Colors.BlanchedAlmond;
                    break;
                case 3:
                    kleur = Colors.Yellow;
                    break;
                case 4:
                    kleur = Colors.Red;
                    break;
                case 5:
                    kleur = Colors.Crimson;
                    break;
                case 6:
                    kleur = Colors.LightBlue;
                    break;
                case 7:
                    kleur = Colors.Cyan;
                    break;
                case 8:
                    kleur = Colors.DarkSeaGreen; // TotH
                    break;
                case 9:
                    kleur = Colors.ForestGreen; //Lock and load
                    break;
                case 10:
                    kleur = Colors.DeepSkyBlue; //focusdump
                    break;
            }
            Logging.Write(kleur, msg);
            LastSpell = msg;
        }
        #endregion logs

        #region AddCounting
        private int addCount
        {
            get
            {
                int count = 0;
                foreach (WoWUnit u in ObjectManager.GetObjectsOfType<WoWUnit>(true, true))
                {
                    if (Me.CurrentTarget != null
                        && u.CanSelect
                        && !u.IsPlayer
                        && u.IsAlive
                        && u.Guid != Me.Guid
                        && !u.IsFriendly
                        && u.IsHostile
                        && u.Attackable
                        && !u.IsTotem
                        && !u.IsCritter
                        && !u.IsNonCombatPet
                        && (u.Location.Distance(Me.CurrentTarget.Location) <= 10 || u.Location.Distance2D(Me.CurrentTarget.Location) <= 10))
                    {
                        count++;
                    }
                }
                return count;
            }
        }
        #endregion AddCounting

        #region Kind of target
        public bool IsBoss
        {
            get
            {
                if (Me.CurrentTarget != null
                    && Me.CurrentTarget.CreatureRank == WoWUnitClassificationType.WorldBoss)
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                    && target.IsBoss(Me.CurrentTarget))
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                    && Me.CurrentTarget.MaxHealth >= (65 * 1000000))
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                    && Me.CurrentTarget.CreatureRank == WoWUnitClassificationType.Elite
                    && Me.CurrentTarget.MaxHealth >= (Me.MaxHealth * 4)
                    && !Me.GroupInfo.IsInParty
                    && !Me.IsInInstance
                    && !Me.GroupInfo.IsInRaid)
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                    && Me.CurrentTarget.CreatureRank == WoWUnitClassificationType.Rare
                    && Me.CurrentTarget.MaxHealth >= (Me.MaxHealth * 4)
                    && !Me.GroupInfo.IsInParty
                    && !Me.IsInInstance
                    && !Me.GroupInfo.IsInRaid)
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                                    && Me.CurrentTarget.CreatureRank == WoWUnitClassificationType.RareElite
                                    && Me.CurrentTarget.MaxHealth >= (Me.MaxHealth * 4)
                                    && !Me.GroupInfo.IsInParty
                                    && !Me.IsInInstance
                                    && !Me.GroupInfo.IsInRaid)
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                    && Me.CurrentTarget.Name.Contains("Training Dummy")
                    && !Me.IsInInstance)
                {
                    return true;
                }
                else if (Me.CurrentTarget != null
                    && Me.CurrentTarget.IsPlayer
                    && !Me.CurrentTarget.IsFriendly)
                {
                    return true;
                }
                return false;
            }
        }

        #endregion Kind of Target
        #region Pet
        public void CallPet()
        {
            if (RaidHunterSettings.myPrefs.autocallrevivepet == 1
                && !Me.Mounted)
            {
                string myPet = "Call Pet " + RaidHunterSettings.myPrefs.callpetnr.ToString();
                if ((Me.Pet == null
                    || !Me.GotAlivePet)
                    && SpellManager.CanCast(myPet)
                    && LastSpell != "CallPet"
                    && !Me.IsCasting)
                {
                    SpellManager.Cast(myPet);
                    Logging.Write(Colors.PaleGreen, myPet);
                    LastSpell = "CallPet";
                    petPresenceTimer.Start();
                }
            }
        }
        public void ReviveMyPet()
        {
            if (RaidHunterSettings.myPrefs.autocallrevivepet == 1
                && !Me.Mounted)
            {
                string myPet = "Call Pet " + RaidHunterSettings.myPrefs.callpetnr;
                if (petPresenceTimer.ElapsedMilliseconds > 2000
                    && !Me.GotAlivePet
                    && LastSpell == "CallPet"
                    && Me.IsAlive
                    && !Me.Mounted
                    && !Me.IsChanneling)
                {
                    if (SpellManager.CanCast("Revive Pet") && !spellOnCooldown(RevivePet))
                    {
                        SpellManager.Cast(RevivePet);
                        Logging.Write(Colors.PaleGreen, "Revive Pet");
                        StyxWoW.SleepForLagDuration();
                        petPresenceTimer.Reset();
                        LastSpell = "RevivePet";
                    }
                }
            }
        }
        #endregion pet

        #region dismount
        public void Dismounted()
        {
            if (Me.Pet == null
                || !Me.GotAlivePet)
            {
                dismountTimer.Start();
            }
        }
        #endregion dismount

        public bool FlaskBuff()
        {
            if (Me.HasAura("Flask of the Warm Sun")) { return true; }
            if (Me.HasAura("Flask of Winter's Bite")) { return true; }
            if (Me.HasAura("Flask of the Earth")) { return true; }
            if (Me.HasAura("Flask of Spring Blossoms")) { return true; }
            if (Me.HasAura("Flask of Falling Leaves")) { return true; }
            if (Me.HasAura("Flask of the Winds")) { return true; }
            if (Me.HasAura("Flask of Titanic Strenght")) { return true; }
            if (Me.HasAura("Flask of the Draconic Mind")) { return true; }
            if (Me.HasAura("Flask of Flowing Water")) { return true; }
            if (Me.HasAura("Flask of Steelskin")) { return true; }
            if (Me.HasAura("Flask of Endless Rage")) { return true; }
            if (Me.HasAura("Flask of Pure Mojo")) { return true; }
            if (Me.HasAura("Flask of Stoneblood")) { return true; }
            if (Me.HasAura("Flask of the Frost Wyrm")) { return true; }
            if (Me.HasAura("Flask of Toughness")) { return true; }
            if (Me.HasAura("Flask of Binding Light")) { return true; }
            return false;
        }
        public void AlchemistFlask()
        {
            if (RaidHunterSettings.myPrefs.alchemyflask == 1)
            {

                if (!Me.HasAura("Enhanced Agility") && !FlaskBuff() && !Me.Mounted)
                {
                    foreach (WoWItem item in Me.BagItems)
                    {
                        if (item != null)
                        {
                            if (item.Name == "Alchemist's Flask")
                            {
                                Lua.DoString("RunMacroText(\"/use " + item.Name + "\")");
                                Logging.Write(Colors.LightBlue, "Using Alchemist's Flask");
                                break;
                            }
                        }
                    }
                }
            }
        }
        public bool myPotion()
        {
            if (Me.CurrentTarget != null
                    && Me.Combat
                    && RaidHunterSettings.myPrefs.virmenpotion == 1)
            {
                WoWItem potion = Me.BagItems.FirstOrDefault(h => h.Entry == 76089);

                if (potion == null
                    && HavePotionBuff != "no")
                {
                    Logging.Write(Colors.BlanchedAlmond, "I have no Agility Potion");
                    HavePotionBuff = "no";
                    return false;
                }
                if (potion != null && potion.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    potion.Use();
                    Logging.Write(Colors.BlanchedAlmond, "Using Agility Potion");
                    HavePotionBuff = "yes";
                    return true;
                }
            }
            return false;
        }
        public bool HealthStone()
        {
            if (Me.Combat
                && Me.HealthPercent <= RaidHunterSettings.myPrefs.healthstonepercent)
            {
                WoWItem hstone = Me.BagItems.FirstOrDefault(h => h.Entry == 5512);
                if (hstone == null
                    && HaveHealthStone != "no")
                {
                    Logging.Write(Colors.BlanchedAlmond, "I have no Healthstone");
                    HaveHealthStone = "no";
                    return false;
                }
                if (hstone != null && hstone.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    hstone.Use();
                    Logging.Write(Colors.BlanchedAlmond, "Using Healthstone");
                    HaveHealthStone = "yes";
                    return true;
                }
            }
            return false;
        }
        public bool myFlask()
        {
            bool useFlask = false;

            if (RaidHunterSettings.myPrefs.agilityflask == 1) { useFlask = true; }

            if (Me.Combat
                && useFlask
                && !FlaskBuff())
            {
                WoWItem flask = Me.BagItems.FirstOrDefault(h => h.Entry == 76084);
                if (flask == null
                    && HaveFlaskBuff != "no")
                {
                    Logging.Write(Colors.BlanchedAlmond, "I have no Agility Flask");
                    HaveFlaskBuff = "no";
                    return false;
                }
                if (flask != null && flask.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    flask.Use();
                    Logging.Write(Colors.BlanchedAlmond, "Using Agility Flask");
                    HaveFlaskBuff = "yes";
                    return true;
                }
            }
            return false;
        }
        #region cooldowns
        public bool Crows
        {
            get
            {
                if (RaidHunterSettings.myPrefs.murderofcrows == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.murderofcrows == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }
                return false;
            }
        }
        public bool Stamp
        {
            get
            {
                if (RaidHunterSettings.myPrefs.stampede == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.stampede == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }
                return false;
            }
        }

        public bool Bloodfury
        {
            get
            {
                if (RaidHunterSettings.myPrefs.bloodfury == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.bloodfury == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }
                return false;
            }
        }
        public bool berserKing
        {
            get
            {
                if (RaidHunterSettings.myPrefs.berserking == 1) { return true; }
                if (RaidHunterSettings.myPrefs.berserking == 2 && IsBoss) { return true; }
                return false;
            }
        }
        public bool Rapidfire
        {
            get
            {
                if (RaidHunterSettings.myPrefs.rapidfire == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.rapidfire == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }
                return false;
            }
        }
        public bool UseTier60
        {
            get
            { 
                if (RaidHunterSettings.myPrefs.useTier60 == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.useTier60 == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }

                return false;
            }
        }
        public bool UseTier75
        {
            get
            { 
                if (RaidHunterSettings.myPrefs.useTier75 == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.useTier75 == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }
     
                return false;
            }
        }
        public bool UseTier90
        {
            get
            { 
                if (RaidHunterSettings.myPrefs.useTier90 == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.useTier90 == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }

                return false;
            }
        }
        public bool UseLifeblood
        {
            get
            {
                if (RaidHunterSettings.myPrefs.lifeblood == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs) { return true; }
                if (RaidHunterSettings.myPrefs.lifeblood == 2 && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs) { return true; }
                return false;
            }
        }
        #endregion cooldowns

        public bool UseReadiness
        {
            get
            {
                if (gotTarget
                    && RaidHunterSettings.myPrefs.Readiness == 1
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.NormalMobs)
                {
                    return true;
                }
                if (gotTarget
                    && RaidHunterSettings.myPrefs.Readiness == 2
                    && IsBoss
                    && Me.CurrentTarget.HealthPercent > RaidHunterSettings.myPrefs.BossMobs)
                {
                    return true;
                }
                return false;
            }
        }

    }
}
